package com.jianneng.jdg.model.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.baidu.location.b.m;
import com.example.com.jianneng.jdg.R;
import com.jianneng.jdg.model.user.ReleaseInfo;

public class ConsultAdapter extends BaseAdapter {
	private List<ReleaseInfo> list = new ArrayList<ReleaseInfo>();
	private Context context;
	private LayoutInflater mInflater;

	public ConsultAdapter(Context context, List<ReleaseInfo> list) {
		this.list = list;
		this.context = context;
		mInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder mHolder = null;
		if(convertView==null){
			mHolder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.consult_listview_item, null);
			mHolder.unread_message_count = (TextView) convertView.findViewById(R.id.unread_message_count);
			mHolder.consult_image = (ImageView) convertView.findViewById(R.id.consult_image);
			mHolder.consult_qustion = (TextView) convertView.findViewById(R.id.consult_qustion);
			mHolder.consult_answer = (TextView) convertView.findViewById(R.id.consult_answer);
			mHolder.consult_time = (TextView) convertView.findViewById(R.id.consult_time);
			convertView.setTag(mHolder);
		}else{
			mHolder = (ViewHolder) convertView.getTag();
		}
		ReleaseInfo info = list.get(position);
		mHolder.unread_message_count.setText(info.unread_message_count+"");
		mHolder.consult_image.setImageResource(R.drawable.notification_message);
		mHolder.consult_qustion.setText(info.question);
		mHolder.consult_answer.setText(info.answer);
		mHolder.consult_time.setText(info.consult_time);
		return convertView;
	}
	public static class ViewHolder{
		TextView unread_message_count;
		ImageView consult_image;
		TextView consult_qustion;
		TextView consult_answer;
		TextView consult_time;
	}

}
